package com.itchu.system.mapper;


import com.itchu.system.domain.Authority;
import com.itchu.system.common.BaseMapper;
import com.itchu.system.domain.SysRole;
import org.apache.ibatis.annotations.*;


import java.util.List;

public interface AuthorityMapper extends BaseMapper<Authority> {

    @Select("select * from authority where parent_id = #{pid}")
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "url", column = "url"),
            @Result(property = "parentId",column = "parent_id"),
            @Result(property = "isParent",column = "is_parent"),
            @Result(property = "children", column = "id",
            many = @Many(select ="com.itchu.system.mapper.AuthorityMapper.showAuthorityByPid"))
    })
    List<Authority> showAuthorityByPid(Long pid);

    void deleteRoleAuthorities(Long rid);

    void addRoleAuthorities(@Param("rid") Long rid, @Param("ids") List<Long> ids);

    List<Authority> findAuthorityById(Long rid);

    List<SysRole> findRoleByRequestURL(String url);

    List<Authority> getDynamicMenus(@Param("rids") List<Long> rids);
}
